<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>

<meta charset="utf-8">
<meta name="generator" content="quarto-1.3.450">

<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">


<title>readme</title>
<style>
code{white-space: pre-wrap;}
span.smallcaps{font-variant: small-caps;}
div.columns{display: flex; gap: min(4vw, 1.5em);}
div.column{flex: auto; overflow-x: auto;}
div.hanging-indent{margin-left: 1.5em; text-indent: -1.5em;}
ul.task-list{list-style: none;}
ul.task-list li input[type="checkbox"] {
  width: 0.8em;
  margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */ 
  vertical-align: middle;
}
</style>


<script src="README_files/libs/clipboard/clipboard.min.js"></script>
<script src="README_files/libs/quarto-html/quarto.js"></script>
<script src="README_files/libs/quarto-html/popper.min.js"></script>
<script src="README_files/libs/quarto-html/tippy.umd.min.js"></script>
<script src="README_files/libs/quarto-html/anchor.min.js"></script>
<link href="README_files/libs/quarto-html/tippy.css" rel="stylesheet">
<link href="README_files/libs/quarto-html/quarto-syntax-highlighting.css" rel="stylesheet" id="quarto-text-highlighting-styles">
<script src="README_files/libs/bootstrap/bootstrap.min.js"></script>
<link href="README_files/libs/bootstrap/bootstrap-icons.css" rel="stylesheet">
<link href="README_files/libs/bootstrap/bootstrap.min.css" rel="stylesheet" id="quarto-bootstrap" data-mode="light">


</head>

<body class="fullcontent">

<div id="quarto-content" class="page-columns page-rows-contents page-layout-article">

<main class="content" id="quarto-document-content">



<section id="grammatrix" class="level1">
<h1>GrammatriX</h1>
<section id="简介" class="level2">
<h2 class="anchored" data-anchor-id="简介">简介</h2>
<p>一个基于生成式大模型的人机英语口语对话网页，前端对话，后端音转文后调用大模型分析用户口语语法，并给出合理纠错建议。 通过这个平台，用户可以进行英语口语练习，同时接受语法错误分析、个性化学习建议等多种辅助功能，帮助他们更有效地提高英语水平。</p>
<p>当前实现技术： - 后端：python 的 Flask - 前端：Vue <img src="./static/demo/演示-前端.png" class="img-fluid"></p>
<p><img src="./static/demo/演示截图.png" class="img-fluid"></p>
</section>
<section id="环境准备" class="level2">
<h2 class="anchored" data-anchor-id="环境准备">环境准备</h2>
<p>确保你的机器上安装了conda和Python 3.9环境。 调用的第三方工具，需要自己账号获得配置信息。有免费额度，前期开发个人足够： 1. 音转文：Google Speech-to-Text，参考配置文档 1. 按官方步骤把.json文件放入本地并按路径配置，也可直接输入下列命令暂时用我的配置文件。 1. mac的生效命令：<code>export GOOGLE_APPLICATION_CREDENTIALS="./resource/service-account-file.json"</code> 2. win的生效命令，cmd中：<code>set GOOGLE_APPLICATION_CREDENTIALS=.\resource\service-account-file.json         2. 也可使用星火的”音转文“，暂未尝试</code> 2. 大模型：讯飞星火大模型3.0，参考<a href="https://xinghuo.xfyun.cn/sparkapi#:~:text=%C2%A50-,%E5%85%8D%E8%B4%B9%E8%AF%95%E7%94%A8,-%E6%9C%8D%E5%8A%A1%E9%87%8F500">配置文档</a>。先免费认领，然后把<a href="https://console.xfyun.cn/services/bm3">你控制台</a>的以下信息粘贴过来。 1. 需要按文档填写在截图中<img src="./static/demo/.png" class="img-fluid"></p>
</section>
<section id="安装步骤" class="level2">
<h2 class="anchored" data-anchor-id="安装步骤">安装步骤</h2>
<ol type="1">
<li>克隆项目到本地：</li>
</ol>
<pre><code>
https://github.com/rollingfruit/GrammatriX.git
</code></pre>
<ol start="2" type="1">
<li>进入项目目录：</li>
</ol>
<pre><code>
cd GrammatriX
</code></pre>
<ol start="3" type="1">
<li>创建一个名为<code>grammar</code>的conda环境，并激活它：</li>
</ol>
<pre><code>
conda create --name grammar python=3.9

conda activate grammar
</code></pre>
<ol start="4" type="1">
<li>安装项目依赖：</li>
</ol>
<pre><code>mac:
pip install -r ./resource/dependencies.txt


win:

pip install -r .\resource\dependencies.txt</code></pre>
<p>注：<code>dependencies.txt</code>文件应包含所有必要的依赖包。此文件可以从项目根目录获取。</p>
<ol start="5" type="1">
<li>启动服务：</li>
</ol>
<pre><code>
python backen.py
</code></pre>
<p>得到后端启动成功页面 <img src="./static/demo/星火模型配置.png" class="img-fluid"></p>
<ul>
<li>启动前端：
<ul>
<li>进入static文件夹，双击打开<code>front.html</code>文件。</li>
<li>按F12，若此时点击”开始录音“按钮不报错，则前后端联调成功。
<ul>
<li>此处若CORS问题，可安装chrome插件”Allow CORS: Access-Control-Allow-Origin“</li>
</ul></li>
</ul></li>
</ul>
</section>
<section id="使用说明" class="level2">
<h2 class="anchored" data-anchor-id="使用说明">使用说明</h2>
<p>详细使用说明请参考项目内的README文档。</p>
</section>
<section id="贡献指南" class="level2">
<h2 class="anchored" data-anchor-id="贡献指南">贡献指南</h2>
<p>我们欢迎任何形式的贡献，包括但不限于新功能、代码审查、文档改进等。</p>
</section>
<section id="许可证" class="level2">
<h2 class="anchored" data-anchor-id="许可证">许可证</h2>
<p>本项目采用MIT许可证。详情请见LICENSE文件。</p>
</section>
</section>
<section id="附" class="level1">
<h1>附</h1>
<section id="极速设置-speech-to-text" class="level2">
<h2 class="anchored" data-anchor-id="极速设置-speech-to-text">极速设置 Speech-to-Text</h2>
</section>
<section id="为-speech-to-text-设置-google-cloud-项目" class="level2">
<h2 class="anchored" data-anchor-id="为-speech-to-text-设置-google-cloud-项目">为 Speech-to-Text 设置 Google Cloud 项目</h2>
<ol type="1">
<li><p><a href="https://console.cloud.google.com/?hl=zh-cn">登录 Google Cloud 控制台</a></p></li>
<li><p><a href="https://console.cloud.google.com/projectselector2/home/dashboard?hl=zh-cn">转到项目选择器页面</a></p>
<p>您可以选择现有项目，也可以创建一个新项目。如需详细了解如何创建项目，请参阅<a href="https://cloud.google.com/resource-manager/docs/creating-managing-projects?hl=zh-cn">创建和管理项目</a>。</p></li>
<li><p>如果您创建新项目，则系统会提示您将一个结算账号关联到该项目。如果您使用的是现有项目，请确保已启用结算功能。</p>
<p><a href="https://cloud.google.com/billing/docs/how-to/modify-project?hl=zh-cn">了解如何确认项目已启用结算功能</a>。</p>
<p><strong>注意</strong>：您必须启用结算功能才能使用 Speech-to-Text API，但除非您超出免费配额，否则不需要支付费用。如需了解详情，请参阅<a href="https://cloud.google.com/speech-to-text/pricing?hl=zh-cn">价格</a>页面。</p></li>
<li><p>选择项目并将其关联到结算账号后，您就可以启用 Speech-to-Text API。转到页面顶部的<strong>搜索产品和资源</strong>栏，然后输入<strong>“speech”</strong>。从结果列表中选择&nbsp;<strong>Cloud Speech-to-Text API</strong>。</p></li>
<li><p>要在不将其与项目关联的情况下试用 Speech-to-Text，请选择<strong>试用此 API</strong>&nbsp;选项。如需启用 Speech-to-Text API 以用于您的项目，请点击<strong>启用</strong>。</p></li>
</ol>
</section>
</section>

</main>
<!-- /main column -->
<script id="quarto-html-after-body" type="application/javascript">
window.document.addEventListener("DOMContentLoaded", function (event) {
  const toggleBodyColorMode = (bsSheetEl) => {
    const mode = bsSheetEl.getAttribute("data-mode");
    const bodyEl = window.document.querySelector("body");
    if (mode === "dark") {
      bodyEl.classList.add("quarto-dark");
      bodyEl.classList.remove("quarto-light");
    } else {
      bodyEl.classList.add("quarto-light");
      bodyEl.classList.remove("quarto-dark");
    }
  }
  const toggleBodyColorPrimary = () => {
    const bsSheetEl = window.document.querySelector("link#quarto-bootstrap");
    if (bsSheetEl) {
      toggleBodyColorMode(bsSheetEl);
    }
  }
  toggleBodyColorPrimary();  
  const icon = "";
  const anchorJS = new window.AnchorJS();
  anchorJS.options = {
    placement: 'right',
    icon: icon
  };
  anchorJS.add('.anchored');
  const isCodeAnnotation = (el) => {
    for (const clz of el.classList) {
      if (clz.startsWith('code-annotation-')) {                     
        return true;
      }
    }
    return false;
  }
  const clipboard = new window.ClipboardJS('.code-copy-button', {
    text: function(trigger) {
      const codeEl = trigger.previousElementSibling.cloneNode(true);
      for (const childEl of codeEl.children) {
        if (isCodeAnnotation(childEl)) {
          childEl.remove();
        }
      }
      return codeEl.innerText;
    }
  });
  clipboard.on('success', function(e) {
    // button target
    const button = e.trigger;
    // don't keep focus
    button.blur();
    // flash "checked"
    button.classList.add('code-copy-button-checked');
    var currentTitle = button.getAttribute("title");
    button.setAttribute("title", "Copied!");
    let tooltip;
    if (window.bootstrap) {
      button.setAttribute("data-bs-toggle", "tooltip");
      button.setAttribute("data-bs-placement", "left");
      button.setAttribute("data-bs-title", "Copied!");
      tooltip = new bootstrap.Tooltip(button, 
        { trigger: "manual", 
          customClass: "code-copy-button-tooltip",
          offset: [0, -8]});
      tooltip.show();    
    }
    setTimeout(function() {
      if (tooltip) {
        tooltip.hide();
        button.removeAttribute("data-bs-title");
        button.removeAttribute("data-bs-toggle");
        button.removeAttribute("data-bs-placement");
      }
      button.setAttribute("title", currentTitle);
      button.classList.remove('code-copy-button-checked');
    }, 1000);
    // clear code selection
    e.clearSelection();
  });
  function tippyHover(el, contentFn) {
    const config = {
      allowHTML: true,
      content: contentFn,
      maxWidth: 500,
      delay: 100,
      arrow: false,
      appendTo: function(el) {
          return el.parentElement;
      },
      interactive: true,
      interactiveBorder: 10,
      theme: 'quarto',
      placement: 'bottom-start'
    };
    window.tippy(el, config); 
  }
  const noterefs = window.document.querySelectorAll('a[role="doc-noteref"]');
  for (var i=0; i<noterefs.length; i++) {
    const ref = noterefs[i];
    tippyHover(ref, function() {
      // use id or data attribute instead here
      let href = ref.getAttribute('data-footnote-href') || ref.getAttribute('href');
      try { href = new URL(href).hash; } catch {}
      const id = href.replace(/^#\/?/, "");
      const note = window.document.getElementById(id);
      return note.innerHTML;
    });
  }
      let selectedAnnoteEl;
      const selectorForAnnotation = ( cell, annotation) => {
        let cellAttr = 'data-code-cell="' + cell + '"';
        let lineAttr = 'data-code-annotation="' +  annotation + '"';
        const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
        return selector;
      }
      const selectCodeLines = (annoteEl) => {
        const doc = window.document;
        const targetCell = annoteEl.getAttribute("data-target-cell");
        const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
        const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
        const lines = annoteSpan.getAttribute("data-code-lines").split(",");
        const lineIds = lines.map((line) => {
          return targetCell + "-" + line;
        })
        let top = null;
        let height = null;
        let parent = null;
        if (lineIds.length > 0) {
            //compute the position of the single el (top and bottom and make a div)
            const el = window.document.getElementById(lineIds[0]);
            top = el.offsetTop;
            height = el.offsetHeight;
            parent = el.parentElement.parentElement;
          if (lineIds.length > 1) {
            const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
            const bottom = lastEl.offsetTop + lastEl.offsetHeight;
            height = bottom - top;
          }
          if (top !== null && height !== null && parent !== null) {
            // cook up a div (if necessary) and position it 
            let div = window.document.getElementById("code-annotation-line-highlight");
            if (div === null) {
              div = window.document.createElement("div");
              div.setAttribute("id", "code-annotation-line-highlight");
              div.style.position = 'absolute';
              parent.appendChild(div);
            }
            div.style.top = top - 2 + "px";
            div.style.height = height + 4 + "px";
            let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
            if (gutterDiv === null) {
              gutterDiv = window.document.createElement("div");
              gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
              gutterDiv.style.position = 'absolute';
              const codeCell = window.document.getElementById(targetCell);
              const gutter = codeCell.querySelector('.code-annotation-gutter');
              gutter.appendChild(gutterDiv);
            }
            gutterDiv.style.top = top - 2 + "px";
            gutterDiv.style.height = height + 4 + "px";
          }
          selectedAnnoteEl = annoteEl;
        }
      };
      const unselectCodeLines = () => {
        const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
        elementsIds.forEach((elId) => {
          const div = window.document.getElementById(elId);
          if (div) {
            div.remove();
          }
        });
        selectedAnnoteEl = undefined;
      };
      // Attach click handler to the DT
      const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
      for (const annoteDlNode of annoteDls) {
        annoteDlNode.addEventListener('click', (event) => {
          const clickedEl = event.target;
          if (clickedEl !== selectedAnnoteEl) {
            unselectCodeLines();
            const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
            if (activeEl) {
              activeEl.classList.remove('code-annotation-active');
            }
            selectCodeLines(clickedEl);
            clickedEl.classList.add('code-annotation-active');
          } else {
            // Unselect the line
            unselectCodeLines();
            clickedEl.classList.remove('code-annotation-active');
          }
        });
      }
  const findCites = (el) => {
    const parentEl = el.parentElement;
    if (parentEl) {
      const cites = parentEl.dataset.cites;
      if (cites) {
        return {
          el,
          cites: cites.split(' ')
        };
      } else {
        return findCites(el.parentElement)
      }
    } else {
      return undefined;
    }
  };
  var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
  for (var i=0; i<bibliorefs.length; i++) {
    const ref = bibliorefs[i];
    const citeInfo = findCites(ref);
    if (citeInfo) {
      tippyHover(citeInfo.el, function() {
        var popup = window.document.createElement('div');
        citeInfo.cites.forEach(function(cite) {
          var citeDiv = window.document.createElement('div');
          citeDiv.classList.add('hanging-indent');
          citeDiv.classList.add('csl-entry');
          var biblioDiv = window.document.getElementById('ref-' + cite);
          if (biblioDiv) {
            citeDiv.innerHTML = biblioDiv.innerHTML;
          }
          popup.appendChild(citeDiv);
        });
        return popup.innerHTML;
      });
    }
  }
});
</script>
</div> <!-- /content -->



</body></html>